import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home/home.vue'
import Layout from '../views/Layout/Layout.vue'
import Login from '../views/Login/Login.vue'


//异步
const Goods = () => import('../views/Goods/goods.vue')
const AddGoods = () => import('../views/Goods/AddGoods.vue')
const Order = () => import('../views/Order/Order.vue')
const order_detail = () => import('../views/Order/order_detail.vue')
const Returned = () => import('../views/Order/Returned.vue')
const Category = () => import('../views/Params/category.vue')
const Params = () => import('../views/Params/params.vue')
const User = () => import('../views/User/User.vue')

Vue.use(VueRouter)

const routes = [
  {
    path: '',
    component: Layout,
    meta: { isLogin: true },
    children: [{
      path: '/',
      name: 'home',
      component: Home
    },
    {
      path: '/goods',
      name: 'goods',
      component: Goods,
    },
    {
      path: '/add_goods',
      name: 'add_goods',
      component: AddGoods
    }, {
      path: '/category',
      name: 'category',
      component: Category
    },{
      path: '/params',
      name: 'params',
      component: Params
    }, {
      path: '/order',
      name: 'order',
      component: Order
    }, {
      path: '/order_detail',
      name: order_detail,
      component: order_detail
    }, {
      path: '/returned',
      name: 'returned',
      component: Returned
    }, {
      path: '/user',
      name: 'user',
      component: User
    }]
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


export default router
